package com.eyas.business.controllor.sellinglessons;

import com.eyas.business.model.jdbcEntity.table.AppointmentInfo;
import com.eyas.business.model.pojo.sellinglessons.ParamDTO;
import com.eyas.business.service.sellinglessons.SellingLessonsService;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

/**
 * @Auther: 王龙龙
 * @Date: 2019/3/30 11:28
 * @Description:
 */
@Controller
@RequestMapping("/eyas/sellinglessons/")
public class SellingLessonsAction {
    @Autowired
    private SellingLessonsService sellingLessonsService;

    @PostMapping("/updateAppointments/{status}")
    @ResponseBody
    public String updateAppointments(@PathVariable("status") String status, String select_objs, HttpSession session) {
        ObjectMapper mapper = new ObjectMapper();
        List<ParamDTO> list = null;
        try {
            list = mapper.readValue(select_objs,new TypeReference<List<ParamDTO>>() {});
            sellingLessonsService.updateAppointments(list,status,session);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "{\"success\":true}";
    }
}
